#define _CRT_SECURE_NO_WARNINGS 1

#include<stdio.h>
#include<math.h>

int main()
{
	for (int i = 0; i <= 100000; i++)
	{
		int wei = 0;
		int sum = 0;
		int t1 = i;
		while (t1 != 0)
		{
			t1 /= 10;
			wei++;
		}
		int t2 = i;
		for (int j = 1; j <= wei; j++)
		{
			int x = t2 % 10;
			sum += pow(x, wei);
			t2 /= 10;
		}
		if (sum == i)
		{
			printf("%d ", i);
		}
	}
	return 0;
}